/*
 * @Date: 2023-02-20 10:05:45
 * @LastEditTime: 2023-03-10 20:15:55
 * @FilePath: /hash-guess-game/src/api/module/transfer.ts
 * 介绍:
 */
import { defaHttp, ApiRes } from "../index";

/**提交购买保险箱结果 */
export async function apiSafeBox(fromData: SafeBox.Req): Promise<true | never> {
  const res = await defaHttp.post<ApiRes<SafeBox.Res>>(
    "/buy/speed/card",
    fromData,
    {
      mode: ["showError"],
    }
  );
  if (res.code !== 200) return await apiSafeBox(fromData);
  return true;
}
/**提交购买保险箱结果 */
export namespace SafeBox {
  export interface Req {
    number: number;
    txid: string;
  }
  export type Res = void;
}
/**提交充值币种余额结果 */
export async function apiRecharge(
  fromData: Recharge.Req
): Promise<true | never> {
  const res = await defaHttp.post<ApiRes<Recharge.Res>>(
    "/recharge/insert",
    fromData,
    {
      mode: ["showError"],
    }
  );
  if (res.code !== 200) return await apiRecharge(fromData);
  return true;
}
/**提交充值币种余额结果 */
export namespace Recharge {
  export interface Req {
    type: StrNumber;
    txid: string;
    /**链ID【56,99,100】 */
    chain: Id;
    /**需要质押的数量 */
    number: number;
    coin_id: Id;
  }
  export type Res = void;
}

/**提交充值币种余额结果 */
export async function apiBuyShareCard(
  fromData: BuyShareCard.Req
): Promise<true | never> {
  const res = await defaHttp.post<ApiRes<BuyShareCard.Res>>(
    "/buy/share/cards",
    fromData,
    {
      mode: ["showError"],
    }
  );
  if (res.code !== 200) return await apiBuyShareCard(fromData);
  return true;
}
/**提交充值币种余额结果 */
export namespace BuyShareCard {
  export interface Req {
    txid: string;
    number: number;
  }
  export type Res = void;
}

